/**
 * Copyright 2009 cestum.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.almirun.common.collections
{
	import flash.events.IEventDispatcher;
	
	/**
	 * A basic interface that defines the behaviour of a linked list structure
	 */
	public interface LinkedList extends IEventDispatcher
	{
		/**
		 * The first node in the sequence
		 */
		function get firstNode():LinkedListNode;
		
		/**
		 * The final node in the sequence
		 */
		function get lastNode():LinkedListNode;
		
		/**
		 * Inserts a node after another node
		 * @param	node	The new node to be inserted
		 * @param	before	The node after which to place the new node
		 */
		function insertAfter(node:LinkedListNode, after:LinkedListNode):void;
		
		/**
		 * Inserts a node before another node
		 * @param	node	The new node to be inserted
		 * @param	before	The node before which to place the new node
		 */
		function insertBefore(node:LinkedListNode, before:LinkedListNode):void;
		
		/**
		 * Inserts a node at the beginning of the list
		 * @param	node	The new node to insert at the beginning
		 */
		function insertAtBeginning(node:LinkedListNode):void;
		
		/**
		 * Inserts a node at the end of the list
		 * @param	node	The new node to insert at the end
		 */
		function insertAtEnd(node:LinkedListNode):void;
		
		/**
		 * Removes a node from the list
		 * @param	node	The node to remove
		 */
		function remove(node:LinkedListNode):void;
		
		/**
		 * Adds a list to the end of this one. This method modifies the value of
		 * this object and does not return a value
		 * @param	list	The linked list to append 
		 */
		function concat(list:LinkedList):void;
		
		/**
		 * Returns the list as an array
		 */
		function toArray():Array;
		
		/**
		 * How far from the first node is from the given node. Returns -1 if the
		 * node is not in the list
		 */
		function getNodeIndex(node:LinkedListNode):int;
	}
}